import axios, { AxiosRequestConfig } from 'axios'

import { IAddress, IOrderProductBoxInfo } from './interface'
import './__mock__'

/** 获取地址消息 */
export const apiGetAddressMsg = async (waybillNo: string, signal?: AxiosRequestConfig['signal']): Promise<IAddress> => {
  return axios
    .post(`/tmsapi/track_waybill/getAddressInfo`, { waybillNo }, { $extra: 'noAuth', signal })
    .then(res => res.$data)
}

/** 获取产品箱信息 */
export const apiGetOrderProductBoxInfo = async (
  waybillNo: string,
  signal?: AxiosRequestConfig['signal'],
): Promise<IOrderProductBoxInfo> => {
  return axios
    .post(`/tmsapi/track_waybill/getOrderProductBoxInfo`, { waybillNo }, { $extra: 'noAuth', signal })
    .then(res => res.$data)
}
